// Copyright 2012 Anno Langen. All Rights Reserved.

package org.anno;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serializable;

/**
 * Basic Movie data.
 */
public class Movie implements Serializable {

  static final long serialVersionUID = 8574533083518679377L;

  final int id;
  final String title;
  final int ratingSum;
  final int ratingCount;
  transient double meanScore;

  Movie(int id, String title, int ratingCount, int ratingSum) {
    this.ratingCount = ratingCount;
    this.ratingSum = ratingSum;
    this.title = title;
    this.id = id;
  }

  double getMeanScore() {
    return meanScore;
  }

  private void readObject(ObjectInputStream in) throws ClassNotFoundException, IOException {
    in.defaultReadObject();
    meanScore = ((double) ratingSum / ratingCount);
  }
}
